Skip to content

Include an error code for each response#32

Merged
Dj-Codeman merged 1 commit intoDj-Codeman:masterfrom
gldraphael:include-error-code
May 6, 2024
Merged

Include an error code for each response#32
Dj-Codeman merged 1 commit intoDj-Codeman:masterfrom
gldraphael:include-error-code

Conversation

@gldraphael
Copy link

This PR updates the output to include a new error field for each item in responses[].
The field will be null if no error exists for that response.

Closes #28

Formatted response when querying an existing domain with cargo run -- --json dns.lookup.dog:

{
   "responses":[
      {
         "queries":[
            {
               "name":"dns.lookup.dog.",
               "class":"IN",
               "type":"A"
            }
         ],
         "answers":[
            {
               "name":"dns.lookup.dog.",
               "class":"IN",
               "ttl":0,
               "type":"A",
               "data":{
                  "address":"51.159.146.31"
               }
            },
            {
               "name":"dns.lookup.dog.",
               "class":"IN",
               "ttl":0,
               "type":"A",
               "data":{
                  "address":"51.159.149.163"
               }
            }
         ],
         "authorities":[],
         "additionals":[],
         "error":null
      }
   ]
}

Formatted response when querying a non-existent domain with cargo run -- --json dns.lookup123.dog:

{
   "responses":[
      {
         "queries":[
            {
               "name":"dns.lookup123.dog.",
               "class":"IN",
               "type":"A"
            }
         ],
         "answers":[],
         "authorities":[
            {
               "name":"dog.",
               "class":"IN",
               "ttl":1800,
               "type":"SOA",
               "data":{
                  "mname":"v0n0.nic.dog.",
                  "rname":"hostmaster.donuts.email.",
                  "serial":1714974458,
                  "refresh_interval":7200,
                  "retry_interval":900,
                  "expire_limit":1209600,
                  "minimum_ttl":3600
               }
            }
         ],
         "additionals":[],
         "error":"NXDomain"
      }
   ]
}

@gldraphael gldraphael marked this pull request as ready for review May 6, 2024 06:07
@Dj-Codeman Dj-Codeman self-requested a review May 6, 2024 19:13
Copy link
Owner

@Dj-Codeman Dj-Codeman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I'll write a few tests for the errors before the release but otherwise this is good.

@Dj-Codeman Dj-Codeman merged commit 67ee484 into Dj-Codeman:master May 6, 2024
@gldraphael gldraphael deleted the include-error-code branch May 7, 2024 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include the status field in the JSON output

2 participants